package com.sky.mapper.user;

import com.sky.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * 用户管理数据层
 */
@Mapper
public interface UserMapper {

    /**
     * 根据openId查询是否有该用户
     * @param openId
     * @return
     */
    @Select("select id, openid, name, phone, sex, id_number, avatar, create_time from user where openid = #{openId}")
    User selectUser(String openId);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into user(openid,create_time) values (#{openid},#{createTime})")
    void insertUser(User user);
}
